# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Marcin Kolenda <marcinkolenda419@gmail.com>
# Contributor: Valentin Haloiu <vially.ichb+aur@gmail.com>
# Contributor: Lukas Linhart <bugs@almad.net>
# Contributor: Marco Elver <marco.elver AT gmail.com>
# Contributor: apkawa <apkawa@gmail.com>

pkgname=python-celery
pkgver=5.3.5
pkgrel=1
pkgdesc='Distributed Asynchronous Task Queue'
arch=('any')
url='http://celeryproject.org/'
license=('BSD')
depends=('python-billiard' 'python-click-didyoumean' 'python-click-plugins' 'python-click-repl'
         'python-kombu' 'python-pytz' 'python-vine')
optdepends=('python-cryptography: for celery.security'
            'python-pymongo: for celery.backends.mongodb'
            'python-msgpack: for using the msgpack serializer'
            'python-pyro: for using Pyro4 message transport'
            'python-redis: for celery.backends.redis'
            'python-sqlalchemy: for celery.backends.database'
            'python-boto3: for SQS transport'
            'python-yaml: for using the yaml serializer'
            'python-pyzmq: for using ZeroMQ transport')
makedepends=('python-setuptools')
# checkdepends on systemd for sysusers hook to create 'bin' user, because celery's test suite requires gid 1 to exist
checkdepends=('python-pytest-celery' 'python-pytest-subtests' 'python-pytest-timeout' 'python-case'
              'python-cryptography' 'python-gevent' 'python-pymongo' 'python-msgpack' 'python-pyro'
              'python-redis' 'python-sqlalchemy' 'python-boto3' 'python-yaml' 'python-pyzmq'
              'python-eventlet' 'python-moto' 'python-pytest-click' 'systemd')
source=("https://pypi.io/packages/source/c/celery/celery-$pkgver.tar.gz"
        celery@.service celery.tmpfiles.d)
options=('!emptydirs')
sha512sums=('21a713438366f73a0af96c2968fbf0a6c1a015a585d3066a42c882a13cc128669d32544f0877fdce0f3ad9aa44eb1c72417f444fd29717edf8753a1631a3cfdf'
            '3c6c9dbdacca2de12d49c03526b34797fd867c14d04115af0d1fda64d2848a5d3f64ceb6d284be319a81d932dc86e69c157b6f5f859f2fa213fc2f43a6052c65'
            '67279b75c3b44d065811c9c90aee006296164000912d5bb97c74956b26ee4ad4f0847e846052a896d379848b869c849300367e676d3f689cf29e3a0c7ae5310b')

build() {
  cd celery-$pkgver
  python setup.py build
}

check() {
  cd celery-$pkgver
  # t/unit/apps/test_multi.py & t/unit/bin/test_multi.py: needs write permission to /var/run/celery
  # t/unit/backends/test_mongodb.py and t/unit/concurrency/test_eventlet.py: https://github.com/celery/celery/discussions/8422
  python -m pytest \
    --deselect t/unit/apps/test_multi.py \
    --deselect t/unit/bin/test_multi.py \
    --deselect t/unit/backends/test_mongodb.py \
    --deselect t/unit/concurrency/test_eventlet.py
}

package() {
  cd celery-$pkgver
  python setup.py install --root="$pkgdir" --optimize=1 --skip-build
  install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
  install -Dm644 "$srcdir"/celery@.service "$pkgdir"/usr/lib/systemd/system/celery@.service
  install -Dm644 "$srcdir"/celery.tmpfiles.d "$pkgdir"/usr/lib/tmpfiles.d/celery.conf
}
